package com.lei.huawei;

import java.util.Scanner;

/**
 * @author: leiGer
 * @Date: 2022/02/23
 * @Time: 0:28
 */
public class ShuZuOpt {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int row= sc.nextInt();
            int col = sc.nextInt();
            if(row <= 9 && col <= 9){
                System.out.println(0);
                int x1 = sc.nextInt();
                int y1 = sc.nextInt();
                int x2 = sc.nextInt();
                int y2 = sc.nextInt();
                if(x1 < col && x2 < col && y1 <row && y2<row){
                    System.out.println(0);
                }else {
                    System.out.println(-1);

                }

            }


        }
        sc.close();
    }

}
